#ifndef		GUI__CallBack_h
#define		GUI__CallBack_h

class IControl;

class ICallBack
{
public:
	ICallBack();
	virtual ~ICallBack();
	virtual void call(IControl * sender) = 0;
};

class CallBackFunc : public ICallBack
{
public:
	typedef void (*Proc)(IControl * sender, void * userData);
public:
	CallBackFunc(Proc proc, void * userData = 0);
	virtual ~CallBackFunc();
	virtual void call(IControl * sender);
private:
	Proc m_proc;
	void * m_userData;
};

template< class Class >
class CallBackClass : public ICallBack
{
public:
	typedef void (Class::*Proc)(IControl * sender);
public:
	CallBackClass(Class * ptr, Proc proc)
		:	ICallBack()
		,	m_ptr(ptr)
		,	m_proc(proc)
	{
	}
	virtual ~CallBackClass()
	{
		m_ptr = 0;
		m_proc = 0;
	}
	virtual void call(IControl * sender)
	{
		((this->m_ptr)->*(this->m_proc))(sender);
	}
private:
	Class * m_ptr;
	Proc m_proc;
};

#endif	//	GUI__CallBack_h

